<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="Style.css"/>
<script type="text/javascript" src="js/jquery-1.6.1.js"></script>
<script type="text/javascript" src="js/jquery.xml2json.js"></script>
<title>But cham doc</title>
<style>
#preview{
	position:absolute;
	border:0px solid #ccc;
	background:#333;
	padding:5px;
	display:none;
	color:#fff;
	}
.size_img{
	width:200px;
	height:200px;
}

</style>
<script> 
this.imagePreview = function(){	
	/* CONFIG */		
		xOffset = 20;
		yOffset = 30;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img class='size_img' src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");			
    },
	function(){
		this.title = this.t;
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
// $(function(){
	// var products={
		
	// }
// });
$.get('data/pen_data.xml',function(xml){
	var products=$.xml2json(xml);
	$('').val();
});
</script>
</head>
<?php 
	include("config/database.php");
	include("includes/functions/split_page_results.php");
	include("includes/functions/general.php");
	include("includes/functions/common_functions.php");
	tep_db_connect() or die('Unable to connect to database server!');
	//$result=tep_db_query('select * from products p inner join products_description pd on p.products_id=pd.products_id  order by p.products_id desc limit 12');	
	$result_categories=tep_db_query('SELECT * from categories_description cd 
									inner join (select *from categories) c on cd.categories_id=c.categories_id');
	// while($products=tep_db_fetch_array($result))
	// {
		// echo $products['products_name'];
	// }
	
?>
<body>
<div id='outer'>

	<?php include('includes/header.php');?>

<div id="noidung">
<?php //require('header.php');
	
?>
	<!--het div banner-->
<div id="banner">
    	<div id="banerleft"><img src="Hinhanh/banner.png" width="798" height="371" /></div>
		<form action="menu" method="post">
        <div id="baneright">		
        	
		<?php 
		while($categories=tep_db_fetch_array($result_categories))
		{?>
			<div id="bannerightlink"><img src="Hinhanh/marker2.png" width="14" height="14" />&nbsp;&nbsp;&nbsp;
			<a href="index.php?action=<?php echo $categories['categories_id'];?>"><?php echo $categories['categories_name'];?></a></div>        	
		<?php 
		}
		?>
      </div>
	  </form>
    </div><!--het div banner-->
<div id="sanpham">	

 <?php 	
	
	if(isset($_REQUEST['chitiet']))
	{
		$products_id=$_REQUEST['chitiet'];
		$result_categories=tep_db_query("SELECT * FROM products_description pd 
														inner join (SELECT * FROM products WHERE products_id=$products_id) p 
												  ON p.products_id=pd.products_id");
		
		
		?>
		<div id="sanphamtrai">
			<div id="tieude">
				<p><img src="Hinhanh/marker1.png" width="8" height="11" />&nbsp;&nbsp;THÔNG TIN CHI TIẾT SẢN PHẨM </p>
				
			</div>
			<?php
				while($chitiet=tep_db_fetch_array($result_categories))
				{
					?>					
						<div class="chitiet_sanpham" style="color:#467D88;"><?php echo $chitiet['products_name']?>
						<p><img src="Hinhanh/<?php echo $chitiet['products_image'];?>" width="150px" height="150px" /></a></p>
						<span style="color:#2698a3">Giá: </span><span style="font-weight:bold;color:red;"><?php echo number_format($chitiet['products_price'],0,',','.')?></span> <span style="color:#2698a3">VNĐ</span>
						<div style="width:770px;padding-left:15px;">
							<?php  echo $chitiet['products_description'];?>
						</div>
						</div>
					<?php 
				}
			?>
		</div>
		<?php
	}
	else 
	{
	//Hien thi san pham nho
	//Load san pham theo categories_id
	$sql="SELECT * from products_description cd 
									inner join products_to_categories ptc on cd.products_id=ptc.products_id 
									inner join products p 
									ON p.products_id=ptc.products_id";
	 if(isset($_REQUEST['action']))
	 {		
		$categories_id=$_REQUEST['action'];
		$sql.=" WHERE ptc.categories_id='$categories_id'";
		//Phan trang
		//function paging($total, $per_page=5, $page=1, $url='', $num_show=5)
		$per_page=12;		
		$page = $_REQUEST['page']?$_REQUEST['page']:1;		
		$url="index.php";
		$num_show=5;	
		$total=mysql_num_rows(mysql_query($sql));
		$paging=paging($total,$per_page,$page,$url,$num_show);		
		$sql.=" LIMIT {$paging['offset']}, $per_page";	
		
	
	 }
	 else {
		$per_page=12;		
		$page = $_REQUEST['page']?$_REQUEST['page']:1;		
		$url="index.php";
		$num_show=5;	
		$total=mysql_num_rows(mysql_query($sql));
		$paging=paging($total,$per_page,$page,$url,$num_show);		
		$sql.=" LIMIT {$paging['offset']}, $per_page";		
		
	 }
	?>
	
<div id="sanphamtrai">
		<div id="tieude">
		  <p><img src="Hinhanh/marker1.png" width="8" height="11" />&nbsp;&nbsp;Sản phẩm tiêu biểu
		</div>		
	<?php 	
	$result_products=tep_db_query($sql);
	while($products=tep_db_fetch_array($result_products))
	{
?>
          
<div id="sanphamnho">
<form action="" method="get">
<table width="100%" border="0" style="text-align:center">
	  <tr>
		<td colspan="2"><?php echo $products['products_name']?></td>
		</tr>
	  <tr>
		<td colspan="2"><a href="Hinhanh/<?php echo $products['products_image'];?>" class="preview" title="<?php echo $products['products_name']?>">
		<img src="Hinhanh/<?php echo $products['products_image'];?>" width="120px" height="120px" /></a></td>
		</tr>
	  <tr>
		<td><span style="color:#2698a3">Giá: </span><span style="font-weight:bold"><?php echo number_format($products['products_price'],0,',','.');?></span> <span style="color:#2698a3">VNĐ</span>	</td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
	  <td colspan="2" style="font-size:10px; color:#2799a4; font-style:italic; font-weight:bold" id="chitiet"><a href="index.php?chitiet=<?php echo $products['products_id']?>">Chi tiết</a></td>
	  
	  </tr>

  </table>
</form>
</div>
<?php
 } ?>

</div>

<?php
}
?>        
 


  <div id="sanphamphai2">
        <img src="Hinhanh/taskbar_title.png" width="37" height="37" /><span style="font-weight:bold;">Liên hệ</span>
  		<table width="100%" border="0">
  <tr>
    <td colspan="2" style="font-size:6px">.........................................................................</td>
    </tr>
	<tr>
    <td style="color:#FFF;padding-left:5px" align="left" >
		<a href="ymsgr:sendim?thanhnhan_it_88">
		<img border="0" align="texttop" src="http://opi.yahoo.com/online?u=thanhnhan_it_88&m=g&t=5&l=us">		
		</a>
		Ms.Nhàn
	</td>
    <td>0909898852</td>
  </tr>
  <tr>
    <td  style="color:#FFF;padding-left:5px" align="left" >
	<a href="ymsgr:sendim?levan_topweb">
		<img border="0" align="texttop" src="http://opi.yahoo.com/online?u=levan_topweb&m=g&t=5&l=us">		
	</a>
	Ms.Vân
	</td>
    <td >0978640600</td>
  </tr>  
  <tr>
    <td style="color:#FFF;padding-left:5px" align="left" >
	<a href="ymsgr:sendim?kieutran2912">
		<img border="0" align="texttop" src="http://opi.yahoo.com/online?u=kieutran2912&m=g&t=5&l=us">		
	</a>
	Ms.Kiều
	</td>
    <td>0985550720</td>
  </tr>
  <tr>
  <td></td>
  <td></td>
  </tr>
</table>

      </div>
        
  <div id="tintuc">
        <img src="Hinhanh/downloadNhac.png" width="43" height="43" />Tin tức 
        <div id="noidungtintuc"><img src="Hinhanh/marker1.png"  width="5" height="5"/><a href="#">&nbsp;Phát hành sách bút thông minh dành cho người lớn</a></div>
        <div id="noidungtintuc"><img src="Hinhanh/marker1.png"  width="5" height="5"/><a href="#">&nbsp;Bút thông minh vừa phát hành 6 tựa truyện cổ tích mới</a></div>
        <div id="noidungtintuc"><img src="Hinhanh/marker1.png"  width="5" height="5"/><a href="#">&nbsp;Sách tiếng Anh dành cho THC</a>S</div>
        <div id="noidungtintuc"><img src="Hinhanh/marker1.png"  width="5" height="5"/>&nbsp;<a href="#">Bút thông minh vừa ra mắt sản phẩm mới K600</a></div><p>
        <div id="noidungtintuc"></div>
        </div>
        <div id="sanphamphai2">Sản phẩm bán chạy
        <div id="sanphambanchay">
        <table width="100%" border="0">
  <tr>
    <td style="text-align:center"><img src="Hinhanh/but-cham-doc-but-cham-doc-touch-talk-but-cham-doc-vtc-but-cham-doc-hoc-hay-but-cham-doc-touch-talk-vtc-but-cham-doc-gia-re.png" width="120" height="120" /></td>
    </tr>
  <tr>
    <td style="text-align:center; color:#39F">Bút chấm đọc TouchTalk</td>
    </tr>
    <tr>
    <td style="text-align:center"><img src="Hinhanh/F15_SGK_dien_tu_1279611345.jpeg" width="100" height="100" /></td>
    </tr>
  <tr>
    <td style="text-align:center; color:#39F">E-Teacher F15</td>
    </tr>
</table>

        </div>
      </div>
    </div>
<div style="height:20px;color:#F6303E;float:right;padding-right:220px">
	<span><?php echo $paging['paging'];?><span>
</div>
<div id="divrong"></div>
</div><!--het div noi dung-->
<!-- Start Footer-->
<div id="footer">
<?php include('includes/footer.php');?>
</div><!--het div outer-->
</div>
</body>
</html>
